package com.xaicode.template.gendata.common;

/**
 * @author Locker xaicode@sina.com
 * @version 1.0
 * @date 2022/5/24 0024 20:28
 */
public class RandomEmail {

    private static final String[] email_suffix = {
            "@hotmail.com", "@googlemail.com", "@gmail.com", "@msn.com", "@aol.com", "@ask.com", "@live.com",
            "@0355.net", "@126.com", "@163.com", "@163.net", "@263.net", "@3721.net",
            "@qq.com", "@yeah.net", "@sina.com", "@sohu.com", "@yahoo.com", "@yahoo.com.cn"
    };

    public static String base = "abcdefghijklmnopqrstuvwxyz0123456789";

    public static int getNum(int start, int end) {
        return (int) (Math.random() * (end - start + 1) + start);
    }

    public static String getEmail(int lMin, int lMax) {
        int length = getNum(lMin, lMax);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = (int) (Math.random() * base.length());
            sb.append(base.charAt(number));
        }
        sb.append(email_suffix[(int) (Math.random() * email_suffix.length)]);
        return sb.toString();
    }


    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            String email = getEmail(1, i);
            System.out.println(email);
        }
    }

}
